<?php

namespace app\controller;

use support\Request;
use Kingbes\Attribute\Annotation;
use think\facade\Db;
use Workerman\Worker;
use app\common\Tool;

#[Annotation(title: "主页")]
class IndexController
{
    #[Annotation(title: "首页")]
    public function index(Request $request)
    {
        return fetch();
    }

    #[Annotation(title: "仪表盘", view: true)]
    public function board(Request $request)
    {
        // 获取数据库连接对象
        $db = Db::connect();
        // 获取MySQL版本信息
        $mysql_version = $db->query('select version() as version')[0]['version'];
        assign([
            'php_version' => PHP_VERSION,
            'workerman_version' =>  Worker::VERSION,
            'webman_version' => Tool::getPackageVersion('workerman/webman-framework'),
            'admin_version' => config("app.admin_versions"),
            'mysql_version' => $mysql_version,
            'os' => PHP_OS,
        ]);
        return fetch();
    }
}
